﻿using System;
using System.Collections.Generic;
using System.Text;

namespace UI.SystemServerConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            SystemServer server = new SystemServer();
            if (!server.InitServer())
                Console.WriteLine("该端口已被占用，请选择其他端口启动服务！");
            else
            {
                Console.WriteLine("服务已经开启。");
                Console.WriteLine("=========================================================");
                Console.WriteLine("控制台指令：");
                Console.WriteLine("OFF          关闭服务");
                Console.WriteLine("ON           开启服务");
                Console.WriteLine("QUIT         退出服务器");
                Console.WriteLine("=========================================================");
                Console.Write("请输入指令：");
            }
            string order = Console.ReadLine();
            do
            {
                if (order.ToUpper() == "OFF")
                {
                    server.ChannelControl(false);
                    Console.WriteLine("服务已关闭。");
                }
                else if (order.ToUpper() == "ON")
                {
                    server.ChannelControl(true);
                    Console.WriteLine("服务已开启。");
                }
                else if (order.ToUpper() == "QUIT")
                {
                    server.QuitServer();
                    return;
                }
                else
                    Console.WriteLine("指令错误！");
                Console.Write("请输入指令：");
                order = Console.ReadLine();

            } while (true);


        }
    }
}
